package
{
	import com.kitchen.AbstractModule;
	import com.kitchen.SequenceLoaders;
	import com.kitchen.ui.loading.ProcessLoading;
	
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	
	[SWF(width="779",height="644", backgroundColor="0xffaa88")]
	public class Main extends Sprite
	{
		//@todo
		private var debugtf:TextField;
		
		//for
		public var token:String = '254066855';	//店主帐号标识
		public var shopId:int = 0;  //店id
		public var shoper:Object;	//店主信息
		public var shop:Object;  //店铺信息
		public var shops:Array;
		public var master:AbstractModule; //个人店
		public var guest:AbstractModule;	//朋友店
		public var mainSkin:BitmapData = null;	//主皮肤
		public var dialogSkin:BitmapData = null;	//模块皮肤
		public var loading:ProcessLoading;	//加载模块
		private var squenceLoad:SequenceLoaders; //顺序加载
		
		
		public function Main()
		{
			super();
			//flash.system.Security.allowDomain('www.meichu.com', 'www.eueang.com', '*.sina.com');
			
			this.loaderInfo.addEventListener(Event.COMPLETE, layout);
		}
		
		private function loadFinish(event:Event):void{
			this.squenceLoad.removeEventListener(SequenceLoaders.LOAD_F, loadFinish);
			this.squenceLoad = null;
			this.loading.visible =false;
			this.loading = null;
			this.master.setConfig(this.mainSkin,this.dialogSkin, this.shoper,  this.shops, this.shop);
			this.addChild(this.master);
		}
		
		private function dataInitError(event:Event):void{
			this.debug('店主数据加载失败');
		}
		
		private function layout(event:Event):void{
			loading = new ProcessLoading(300, 10);
			loading.x = 200;
			loading.y = 300;
			this.debugtf = new TextField();
			this.debugtf.x = 200;
			this.debugtf.y = 200;
			//this.account = new AccountVo('bewell@foxmail.com', '哈根达斯', 'http://www.meichu.com/static/images/50.jpg', 123, 56, 23, 89, 62, 7564);
			this.addChild(loading);
			this.squenceLoad = new SequenceLoaders(this);
			this.squenceLoad.addEventListener(SequenceLoaders.LOAD_F, loadFinish);
		}
		
		public function debug(message:String):void{
			this.debugtf.text = 'debug:'+message;
		}
	}
}